/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kungkhies.common.services.kungkhie.validate.xml;

import com.kungkhies.common.services.kungkhie.parse.KungkhieParseService;
import com.kungkhies.xml.schema.kungkhie.ArcListType;
import com.kungkhies.xml.schema.kungkhie.ArcType;
import com.kungkhies.xml.schema.kungkhie.IloListType;
import com.kungkhies.xml.schema.kungkhie.IloType;
import com.kungkhies.xml.schema.kungkhie.KungkhieDocument;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author clayton
 */
public class KungkhieXmlValidateServiceImplTest_IloList
{
    public KungkhieXmlValidateServiceImplTest_IloList()
    {
    }
    
    @BeforeClass
    public static void setUpClass()
    {
    }
    
    @AfterClass
    public static void tearDownClass()
    {
    }
    
    @Before
    public void setUp()
    {
    }
    
    @After
    public void tearDown()
    {
    }

    

    /**
     * Test of validateKungkhieType method, of class KungkhieXmlValidateServiceImpl.
     */
    @Test
    public void testValidateKungkhieIloList_Cardinality() throws Exception
    {
        System.out.println("validateKungkhieArcList_Cardinality");
        KungkhieDocument kungkhieDocument = null;
        KungkhieXmlValidateServiceImpl instance = new KungkhieXmlValidateServiceImpl();
        String pathToFile = "resources/example-kungkhie-1.xml";
        String filename = "validateContent.txt";
        kungkhieDocument = instance.createKungkhieDocument(pathToFile, filename);
        
        IloListType iloList = kungkhieDocument.getKungkhie().getIloListArray(0);
        
        IloType[] iloArray = iloList.getIloArray();
        
        int iloArrayCardinality = iloArray.length;
        
        int iloArrayCardinalityExpected = 2;
        
        assertEquals(iloArrayCardinalityExpected, iloArrayCardinality);
    }
    
    /**
     * Test of validateKungkhieType method, of class KungkhieXmlValidateServiceImpl.
     */
    @Test
    public void testValidateKungkhieIloList_PackageAttribute() throws Exception
    {
        System.out.println("validateKungkhieArcList_Cardinality");
        KungkhieDocument kungkhieDocument = null;
        KungkhieXmlValidateServiceImpl instance = new KungkhieXmlValidateServiceImpl();
        String pathToFile = "resources/example-kungkhie-1.xml";
        String filename = "validateContent.txt";
        kungkhieDocument = instance.createKungkhieDocument(pathToFile, filename);
        
        IloListType iloList = kungkhieDocument.getKungkhie().getIloListArray(0);
        
        String iloPackageName = iloList.getIloPackage();
        
        String iloPackageNameExpected = "unique.ilo.package.name";
        
        assertEquals(iloPackageNameExpected, iloPackageName);
        
    }
    
     /**
     * Test of validateKungkhieType method, of class KungkhieXmlValidateServiceImpl.
     */
    @Test
    public void testValidateKungkhieIloList_Ilo() throws Exception
    {
        System.out.println("validateKungkhieArcList_Ilo  ");
        KungkhieDocument kungkhieDocument = null;
        KungkhieXmlValidateServiceImpl instance = new KungkhieXmlValidateServiceImpl();
        String pathToFile = "resources/example-kungkhie-1.xml";
        String filename = "validateContent.txt";
        kungkhieDocument = instance.createKungkhieDocument(pathToFile, filename);
        
        IloListType iloList = kungkhieDocument.getKungkhie().getIloListArray(0);
        
        IloType[] iloArray = iloList.getIloArray();
        
        String iloID1 = iloArray[0].getIloID();
        String iloID2 = iloArray[1].getIloID();
        
        String iloID1Expected = "com.example.ilo-1";
        String iloID2Expected = "com.example.ilo-2";
        
        assertEquals(iloID1Expected, iloID1);
        assertEquals(iloID2Expected, iloID2);
        
        String ilo1 = iloArray[0].getStringValue();
        String ilo2 = iloArray[1].getStringValue();
        
        String ilo1Expected = "Do this.";
        String ilo2Expected = "Do that.";
        
        assertEquals(ilo1Expected, ilo1);
        assertEquals(ilo2Expected, ilo2);
    }
}
